{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6c2d7762",
   "metadata": {},
   "source": [
    "## 上周回顾\n",
    "\n",
    ">* list一般方法/函数 的所有使用场景及案例，方法如：\n",
    ">> 1.append（）   \n",
    ">> 2.pop（index）\\remove(values)    \n",
    ">> 3.count()   \n",
    ">> 4.indev()   \n",
    ">> 5.extend()   \n",
    ">> 6.sort()   \n",
    ">>...   \n",
    ">* list 的高级方法 如：   \n",
    ">> 1.copy() =[:]    \n",
    ">> 2.enu    \n",
    ">* 课本练习 Don't panic ==> on tap   \n",
    ">> 1.list的一些方法实现     \n",
    ">> 2.list的切片实现      \n",
    ">> 3.str => list 的方法 list(str)     \n",
    ">> 4.list => str 的方法 '',join(list)     \n",
    "\n",
    "## 本周内容\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "fed8da12",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-8-1b4a8d37600d>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-8-1b4a8d37600d>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    1.vowels\u001b[0m\n\u001b[1;37m      ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "1.vowels  \n",
    "2.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "263a1268",
   "metadata": {},
   "outputs": [],
   "source": [
    "vowels = ['a','e','i','o','u'] # 这是元音（list）\n",
    "word = \"Milliways\" # 这是文本（str）\n",
    "# 需求：word中出现的 vowels 打印出来\n",
    "# for 循环的第一个元素要注意，第二个元素决定要循环什么内容\n",
    "# 循环的列表，每个元素单独在一行出现\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3d717398",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i\n",
      "i\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "for letter in word: # letter可以随便命名，不会影响结果\n",
    "                    # 一般情况下，list(内容) =>简写为 i\n",
    "#    print(letter)\n",
    "    if letter in vowels:\n",
    "        print(letter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5024f624",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a', 'e', 'i', 'o', 'u']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# append ()经常用于新建列表               \n",
    "found = []\n",
    "for letter in vowels:\n",
    "    if letter in vowels:\n",
    "        if letter not in found:\n",
    "            found.append(letter)\n",
    "found"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6750139b",
   "metadata": {},
   "outputs": [],
   "source": [
    "数据结构练习1\n",
    " 购物车练习项目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3aede74d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 准备工作\n",
    "# 1 商品信息\n",
    "good_list = [\n",
    "    [\"milk\", 20],\n",
    "    [\"coffee\" , 30],\n",
    "    [\"tea\",50]\n",
    "]\n",
    "# 2 用户购物信息\n",
    "user_shopping_list = []\n",
    "\n",
    "# 用户输入（余额）：\n",
    "\n",
    "# 输入正确，打印商品列表\n",
    "Alipay = int(input(\"请输入您的余额:\"))\n",
    "info = '''-----good detail-----\n",
    "编号0，商品名称：%s,商品价格：%s 元\n",
    "编号1，商品名称：%s,商品价格：%s 元\n",
    "编号2，商品名称：%s,商品价格：%s 元\n",
    "'''%(goods_list[0][0],goods_list[0][1],\n",
    "    goods_list[1][0],goods_list[1][1],\n",
    "    goods_list[2][0],goods_list[2][1])\n",
    "print(info)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d327c9e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
